import {HTTP} from '../utils/http'

class HeartModel extends HTTP{
  list(current,type,size,themeId){
    return this.request({
      url:'voice/selectPage',
      data:{
        size: size || 10,
        current: current || 1,
        cond: JSON.stringify({type: type || 1, themeId: themeId || ''})
      }
    })
  }

  
  detail(id){
    return this.request({
      url:'voice/selectById',
      data: {cond: JSON.stringify({'id': id})}
    })
  }

  praise(id,isPraise){
    var url = ""
    if (isPraise) {
      url = "cancelById"
    }else{
      url = "insert"
    }
    return this.request({
      url:'userZan/' + url,
      data: {
        id: id, 
        type: 3
      }
    })
  }

  collection(id,isCollection,type){
    var url = ""
    if (isCollection) {
      url = "cancelById"
    }else{
      url = "insert"
    }
    return this.request({
      url:'userFollow/' + url,
      data: {
        id: id, 
        type: type || 3
      }
    })
  }
  insert(content,imgs,themeId){
    return this.request({
      url:'voice/insert',
      data: {content: content,imgs:imgs,themeId:themeId}
    })
  }
  getCommentList(size,current,heartId){
    return this.request({
      url:'voiceComment/getCommentList',
      data: {
        size: size || 10,
        current: current || 1,
        cond: JSON.stringify({id: heartId})
      }
    })
  }
  voiceComment(content,voiceId){
    return this.request({
      url:'voiceComment/save',
      data: {content: content,voiceId:voiceId}
    })
  }
}




export {HeartModel}